/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Scanner;

/**
 * <p>Project: app2022 - ScannerTest
 * <p>Powered by webrx On 2022-01-08 12:36:05
 *
* @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class ScannerTest {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //sc.close();
        sc.reset();
        while (true) {
            System.out.println("请输入整数：");
            int temp = 0;
            //System.out.println("1" + sc.hasNextLine());
            if (sc.hasNextInt()) {
                temp = sc.nextInt();
            } else {
                String s = sc.nextLine();
                if (s.contains("quit")) {
                    System.out.println("程序退出");
                    sc.close();
                    break;
                } else {
                    System.out.println("程序有误");
                    sc.reset();
                    continue;
                }
            }
            System.out.println(temp);

            //sc.reset();
        }

    }
}
